Running your programs

You can run a program by using the menus by selecting Run under the Debug menu (henceforth to be abbreviated Debug\Run) or by clicking the lighting bolt on the speedbar. A window will come up telling you that your program in being "compiled", then "linked", and finally a new window will open which shows the output to your program. Suppose we have entered the following program:

#include &ltiostream.h>int main()

{

	cout << "Hey! I wrote my first program!" << endl;

}

If you want to follow along, you can run Borland and either type or copy-and-paste it into a program window. To copy and paste, just point the mouse at the beginning of the program in the Netscape window, hold down the left mouse button, and then move the mouse to the end of the program text. The program code should become highlighted in black. Then selected Edit\Copy in the Netscape menus, run (or switch to) Borland 4.5, get yourself a new program window, and select Edit\Paste from the Borland menus. You should see something like this when you are done:

If we now run the program by hitting the run button, we see the compiling and linking window, and finally our program runs. Whenever you run a program, an input/output window is created. This is what we see:

Whenever you run a program it will produce a window for input and output. We can see the words "Hey! I wrote my first program!" at the top of the window; this text was output from our program. This window will also be where you type in input to a program. At the top of the window we see than name of the program that was run, "noname01.exe". (This is just the original name of the program, excepte with a ".exe" extension instead of ".cpp".)

The top bar of the window also shows that the program is Inactive; this just means it has finished running. At this point, to return to Borland we should close the program's run-window. (As with any other window, this can be done by double-clicking in the upper-lefthand corner of the window, or pulling down the menu from that corner and selecting Close.) If you fail to close the run-window, Borland will give you a problem if you try to run the program again. If you want to run your program, but Borland won't let you, as signified by the fact the the run button on the speedbar is not lit and the menu option Debug/Run is unavailable:

you may be able to fix the problem by selecting Debug/Terminate program or sometimes Project/Build All. Then try to run the program again. If this doesn't work, ask a lab consultant for help.